<template>
  <div class="wty-shop-ball">
    <div class="wty-shop-ball-left mx-middle">
      <transition name="wty-rotate">
        <div class="wty-outer" v-show="count !== 0">
          <transition name="wty-move">
            <span
              v-show="count !== 0"
              class="el-icon-remove-outline"
              @click="_minusCount"
            ></span>
          </transition>
        </div>
      </transition>
    </div>
    <div class="wty-shop-ball-count mx-middle">
      <span v-show="count !== 0" class="count">{{ count }}</span>
    </div>
    <div class="wty-shop-ball-right mx-middle">
      <span class="el-icon-circle-plus-outline" @click="_addCount"></span>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    count: 0
  }, // 接受参数
  methods: {
    _addCount() {
      // 调用父组件
      this.$emit("addCount");
    },
    _minusCount() {
      // 调用父组件
      this.$emit("minusCount");
    }
  }
};
</script>

<style lang="scss" scoped>
.wty-shop-ball {
  display: flex;
  width: 100%;
  height: 100%;
  justify-content: flex-end;
  .wty-shop-ball-left {
    flex: 1;
    .wty-outer {
      width: 18px;
      height: 18px;
      .el-icon-remove-outline {
        font-size: 18px;
        color: #ffbd27;
      }
      .wty-move-enter-active,
      .wty-move-leave-active {
        transition: all 2s;
      }
      .wty-move-enter,
      .wty-move-leave-to {
        opacity: 0;
        transform: rotate(1440deg);
      }
    }
    .wty-rotate-enter-active,
    .wty-rotate-leave-active {
      transition: all 1s;
    }
    .wty-rotate-enter,
    .wty-rotate-leave-to {
      opacity: 0;
      transform: translate3d(30px, 0, 0);
    }
  }
  .wty-shop-ball-count {
    flex: 1;
    font-size: 14px;
    font-weight: 700;
  }
  .wty-shop-ball-right {
    flex: 1;
    .el-icon-circle-plus-outline {
      font-size: 18px;
      color: #ffbd27;
    }
  }
}
</style>
